﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OOSE_TDD
{
    public class Webshop
    {
        private IEmail myIEmail;


        public Customer newCustomer(string firstName, string lastName, string birthday,
                                 string street, string postCode, string city,
                                 string country, string mailAdress)
        {
            Customer customer = new Customer();

            customer.FirstName = firstName;
            customer.LastName = lastName;
            customer.Birthday = birthday;
            customer.Street = street;
            customer.PostCode = postCode;
            customer.City = city;
            customer.Country = country;
            customer.MailAdress = mailAdress;

            return customer;
        }

        public Article newArticle(string articleName, string description, decimal taxRate, decimal grossPrice)
        {
            Article article = new Article();

            article.ArticleName = articleName;
            article.Description = description;
            article.TaxRate = taxRate;
            article.GrossPrice = grossPrice;

            return article;
        }

        public void validate(Customer myCustomer, Article myArticle)
        {
            string message = "";
            if (doSendMethod(myCustomer, myArticle) == false)
            {
                message = "DIe Email konnte nicht gesendet werden.";
                Console.WriteLine(message);
            }
            else
            {
                message = "Die Email wurde erfolgreich gesendet";
                Console.WriteLine(message);
            }
        }

        public bool doSendMethod(Customer myCustomer, Article myArticle)
        {
            myIEmail = new MockService();
            // hier soll der Aufruf der Email vorgetäuscht werden
            // es wird also das Mockobjekt verwendet
            return myIEmail.isSend(myCustomer, myArticle);
        }

    }
}
